<!DOCTYPE HTML>
<html>
<HEAD>
<meta charset="utf-8">
<TITLE>员工管理</TITLE>
</HEAD>
<body>
    
<?php
include_once("base-class.php");

//新建sae数据库类
$mysql = new SaeMysql();

//获取当前页码
$roster_class=intval($_GET["id"]);



//列表数据获取、分页

//计算总数
$count=$mysql->getVar("select COUNT(*) from roster where roster_class=$roster_class and status=1");
//如果数据表里有数据
if($count)
{
    //每页显示记录数
    $page_num = 10;
    //如果无页码参数则为第一页
    if ($page == 0) $page = 1;
    //计算开始的记录序号
    $from_record = ($page - 1) * $page_num;
    //获取符合条件的数据
    $roster_list=$mysql->getData("select A.*,B.class_name
                from roster A left join class B on A.roster_class=B.class_id where A.roster_class=$roster_class and A.status=1 
                order by A.roster_id desc 
                limit $from_record,$page_num");
    //分页函数
    $multi = multi($count, $page_num, $page, "roster_manager.php");
}
?>
    
    <table border=1>
        <tr>
            <td>姓名</td><td>工号</td><td>照片</td><td>性别</td><td>部门</td><td>手机</td><td>状态</td><td>操作</td>
        </tr>
        <?php
			if($roster_list)
            {
                $roster_status_arr=array('',"在职","休假","病假","离职");
                foreach($roster_list as $value)
                {
                    
                    $value["roster_sex"]=($value["roster_sex"]==1)?"男":"女";
                    $value["roster_status"]=$roster_status_arr[$value["roster_status"]];
                    echo "<tr>
                          <td>$value[roster_name]</td>
                          <td>$value[roster_number]</td>
                          <td><img src=\"$value[roster_pic]\" height=\"150\"></td>
                          <td>$value[roster_sex]</td>
                          <td>$value[class_name]</td>
                          <td>$value[roster_mp]</td>
                          <td>$value[roster_status]</td>
                          <td>
                            <a href='roster_manager.php?action=del&roster_id=$value[roster_id]'>删除</a>
                            <a href='roster_add.php?roster_id=$value[roster_id]'>修改</a>
                          </td>
                          <tr>";
                }
            }
			else
            {
                echo "<tr><td colspan=8>无记录</td></tr>";
            }
        ?>
    
    </table>
<div style="font-size:40px">
    <?php
    
	echo $multi;
    ?>
    </div>
</body>
</html>
